Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: run flycheck without rev_deps when target is specified #17912

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

alibektas
Copy link
Member

@alibektas alibektas commented Aug 16, 2024

Since querying for a crate's target is a call to salsa and therefore blocking, flycheck task is now deferred out of main thread by using GlobalStates deferred_task_queue. Fixes #17829 and rust-lang/rustlings#2071

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 16, 2024
@alibektas alibektas changed the title Cargo check on binary fix: run flycheck without rev_deps when target is binary Aug 16, 2024
@alibektas
Copy link
Member Author

It has been mentioned that this particular case is not only limited to binary targets. I would be happy to add also other cases.

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay two things, I think I was wrong with this requiring a queued task as we have already been doing all the work within the spawned task (and can still continue to do so), so we can undo that part. The other thing is that when we do have the binary case here, we should not only skip the reverse dependency stuff, we should also tell flycheck to pass --bin <bin-name> for its check, that will require some more changes in the flycheck restart logic

@alibektas alibektas force-pushed the cargo_check_on_binary branch from 9fbff41 to ffc3bfe Compare August 20, 2024 23:40
@@ -396,6 +400,10 @@ impl FlycheckActor {
None => cmd.arg("--workspace"),
};

if let Some(tgt) = bin_target {
cmd.arg("--bin").arg(tgt);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should also pass the package here (non-optional). Two packages in a workspace can have the a binary with the same name. In that case, Cargo checks both of them (tested it).

Copy link
Member

@Veykril Veykril Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine to support either, the package is passed above if a package was set (which should be usually the case). Or does rustlings name all binaries the same? (I hope not)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for Rustlings. But if we extend this to tests instead of only bins, a workspace could have multiple packages with the test integration_tests for example. I don't see why rust-analyzer should check all of them if only one changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, I'd still leave the logic as is though and just change the restart callers as this invocation isn't technically invalid.

crates/rust-analyzer/src/handlers/notification.rs Outdated Show resolved Hide resolved
crates/rust-analyzer/src/flycheck.rs Outdated Show resolved Hide resolved
Comment on lines +304 to +305
// Trigger flychecks for the only workspace which the binary crate belongs to
world.analysis.crates_for(file_id)?.into_iter().unique().collect::<Vec<_>>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should already have that information in the TargetSpec, it should contain the relevant crate id

Copy link
Member Author

@alibektas alibektas Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only bit I couldn't really come up with a solution to because the package information for RustProjectJson is not really clear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, #17946 the data was there but not exposed that's all

@alibektas alibektas changed the title fix: run flycheck without rev_deps when target is binary fix: run flycheck without rev_deps when target is specified Aug 22, 2024
@Veykril
Copy link
Member

Veykril commented Aug 23, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Aug 23, 2024

📌 Commit 03456c5 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 23, 2024

⌛ Testing commit 03456c5 with merge 44fd708...

@bors
Copy link
Contributor

bors commented Aug 23, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 44fd708 to master...

@bors bors merged commit 44fd708 into rust-lang:master Aug 23, 2024
11 checks passed
@alibektas alibektas deleted the cargo_check_on_binary branch September 12, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass --bin to cargo check when a binary is changed
5 participants